define(['artTemplate' , 'modalMobile' , '../../common/ajax/ajax' , '../../../common/js/lib/text!../../../tpl/header.tpl' , '../../../common/js/lib/text!../../../tpl/footer.tpl' , '../../../common/js/lib/text!../../../tpl/report-list.tpl' , '../v/state'] ,
 function(artTemplate , modalMobile , ajax , header , footerTpl , reportTpl , states) {
  var headerConfig = {
    title:"安装数据",
    rightBtn:"已上报数据",
    rightLink:'/h5-wizard/index.html#has-report',
  };
  function noReportV(listData){
    var headerEl = artTemplate.compile(header),
        footer = artTemplate.compile(footerTpl)({type:3}),
        reportList = artTemplate.compile(reportTpl)({
          btn:true,
          data:listData.data,
        }),
        el = headerEl(headerConfig);
    $('.webApp-content').html(el+reportList+footer);
    //上报
    $("#update-btn").click(function(){
      var _data = JSON.stringify({type:2});
      ajax({
          url:interfaces.manage_installed_data.url,
          dataType:interfaces.manage_installed_data.dataType,
          type:interfaces.manage_installed_data.type,
          data:_data,
          cache:{
              use:false,
              name:'',
              time:10
          },
          isOk:function(data){
            if(useNetData){
              data = data;
            }else{
              data = data.manage_installed_data;
            };
            if(data.data.netstat == 0){
              modalMobile.alert('网络连接异常' , {
                btn:['确定']
              });
            }else{
              states({
                title:'上报成功' ,
                type:'ok',
                info:'上报('+data.data.all_num+')条 成功('+data.data.reported_num+')条'
              } , {
                title:'上报成功',
                leftLink:'/h5-wizard/index.html#no-report'
              });
            };
          },
      });
    });
  };
  return noReportV;
});
